Release 10.1A: OpenEdge Development:
Progress 4GL Handbook
The ETIME function
You might be wondering (in fact, you should be wondering) how to tell which of two constructs is faster in your situation or how to measure the performance of a part of your application. Progress has a performance profiling tool (called Profiler) that can show you exactly how much of your processing time is going to what routines, but there is also a much simpler way to do a test of a specific part of your code: the
ETIMEfunction (for elapsed time).ETIMEreturns an integer value representing the number of milliseconds since the function was reset to zero. Because a millisecond is a substantial amount of time on a modern processor, you often have to repeat an action many times inside a loop to measure accurately just what its cost is.To reset the counter that
ETIMEuses, you invoke the function with an argument value of yes or true. Otherwise, you invoke it with no argument and no parentheses. If you forget to reset it to zero before you start,ETIMEreturns some enormous integer representing the number of milliseconds since your session started.This example shows you whether it is faster to use the
FINDstatement or aFOR FIRSTblock to find the Order with a Customer Number of 24 and an Order Date of 1/31/98.If you look at the indexes for the Order table in the Data Dictionary, you see that there is an index on the Order Date field, and another index that has the CustNum field as its primary component, followed by the OrderNum field. The
FOR FIRSTconstruct takes advantage of both of these indexes to resolve the request in the most efficient way possible. TheFINDstatement can use only one of the indexes.The code first resets
ETIME, then does the sameFINDin a loop 10000 times. It then saves theETIMEcounter for this operation. Then it resets it again, does aFOR FIRST10000 times, saves that value, and finally displays both values:
Figure 21–2 shows the result.
Figure 21–2: Result of ETIME function example
![]()
So, the
FOR FIRSTwas significantly faster. The actual difference is very dependent on the actual indexes and the number of records to search.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |